﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace RapidDownloader.Markup
{
    public sealed class RelativeConverter : IValueConverter
    {
        #region Fields

        public static readonly IValueConverter Instance = new RelativeConverter();

        #endregion

        #region Public Methods

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var length = System.Convert.ToDouble(value);
            var rel = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);
            return length * rel;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}